package com.sse.log.log4j2;

import java.io.FileInputStream;

import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Configurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class produceLogs {
	
	private static Logger logger = null;
	
	private static int number = 0;
	
	static{
		///Load Log4j Configuration.
		try {
			
			loadLog4j2("/conf/log4j2.xml");
			
			logger = LoggerFactory.getLogger(produceLogs.class);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private static void sleep(long millis) throws Exception{
		Thread.sleep(millis);
	}
	
	public static void loadLog4j2(String path) throws Exception{
		ConfigurationSource source;  
        source = new ConfigurationSource(new FileInputStream(produceLogs.class.getResource(path).getPath()));  
        Configurator.initialize(null, source); 
	}
	
	public static void main(String[] args) throws Exception {
        System.out.println(produceLogs.class.getResource("").getPath());
		while(number < 86400){
			logger.info("Log test, serialNumber: {}", number);
			sleep(1000);
			number ++;
			if(number > 86390){
				number = 0;
				logger.info("Log number increased overflow. Set Zero.");
			}
		}
		
	}

}
